import {BasicColumn, FormSchema} from '@/components/Table';

import {Calendar,Tag} from 'ant-design-vue';
import { h } from 'vue';

type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
  {
    title: 'ms采购单号',
    dataIndex: 'orderNo',
    width: 150,
  },
  {
    title: '采购金额',
    dataIndex: 'orderPrice',
  },
  {
    title: '供应商编号',
    width: 100,
    dataIndex: 'supplierNo',
  },
  {
    title: '供应商名称',
    dataIndex: 'supplierName',
  },
  {
    title: '签单日期',
    dataIndex: 'orderDate',
    width: 110,

  },
  {
    title: '虚拟物料编号',
    dataIndex: 'materialNo',
    width: 120,

    //mp3Url remoteUrl
  },
  {
    title: '虚拟物料名称',
    dataIndex: 'materialName',
  },
  // {
  //   title: '物料规格',
  //   dataIndex: 'specification',
  // },
  // {
  //   title: '物料型号',
  //   width: 100,
  //   dataIndex: 'model',
  // },
  {
    title: '下单数量',
    dataIndex: 'orderNum',
    width: 100,
  },
  {
    title: '是否符合退款条件',
    dataIndex: 'isReturn',
    width: 80,
    customRender: ({ record }) => {
      const type = record.isReturn;
      let text="否";
      let color="";
      switch (type) {

        case 0:
          text="否";
          break;
        case 1:
          text="是;并点击查看明细";
          color="green"
          break;

      }
      // return text;
      // return h(Tag, {color}, () => text);
      return h('div', {
        class: 'isReturn_clazz',
        style: {
          color
        },
      },text)
    },
  },
  {
    title: '是否关闭',
    dataIndex: 'isClose',
    width: 80,
    customRender: ({ record }) => {
      const type = record.isClose;
      let text="否";
      let color="";
      switch (type) {
        case 0:
          text="否";
          break;
        case 1:
          text="是";
          color="red"
          break;
      }
      // return text;
      return h(Tag, {color}, () => text);

    },
  },
  {
    title: '批号',
    dataIndex: 'no',
    width: 130,
  },
  {
    title: '下单人',
    dataIndex: 'userName',
    width: 100,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 100,
  },

];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderNo',
    label: '采购单号',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'supplierName',
    label: '供应商名称',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'materialName',
    label: '物料名称',
    component: 'Input',
    colProps: { span: 5 },
  },
  // {
  //   field: 'IfXuNiJian',
  //   label: '是否查询虚拟件',
  //   component: 'Select',
  //   colProps: { span: 5 },
  //   defaultValue: 1,
  //   componentProps: {
  //     options: [
  //       { label: '是', value: 1 },
  //       { label: '否', value: 0 },
  //     ],
  //   },
  // },
  {
    field: 'orderDateStart',
    label: '签单起始日期',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
    colProps: { span: 5 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '成员名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'isRead',
    label: '是否参与读书',
    component: 'Select',
    componentProps: {
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
  },
];
